package services

import (
	"bbs-go/internal/models"
	"bbs-go/internal/repositories"

	"github.com/mlogclub/simple/sqls"
	"github.com/mlogclub/simple/web/params"
)

var UserLoginLogService = newUserLoginLogService()

func newUserLoginLogService() *userLoginLogService {
	return &userLoginLogService{}
}

type userLoginLogService struct {
}

func (s *userLoginLogService) Get(id int64) *models.UserLoginLog {
	return repositories.UserLoginLogRepository.Get(sqls.DB(), id)
}

func (s *userLoginLogService) Take(where ...interface{}) *models.UserLoginLog {
	return repositories.UserLoginLogRepository.Take(sqls.DB(), where...)
}

func (s *userLoginLogService) Find(cnd *sqls.Cnd) []models.UserLoginLog {
	return repositories.UserLoginLogRepository.Find(sqls.DB(), cnd)
}

func (s *userLoginLogService) FindOne(cnd *sqls.Cnd) *models.UserLoginLog {
	return repositories.UserLoginLogRepository.FindOne(sqls.DB(), cnd)
}

func (s *userLoginLogService) FindPageByParams(params *params.QueryParams) (list []models.UserLoginLog, paging *sqls.Paging) {
	return repositories.UserLoginLogRepository.FindPageByParams(sqls.DB(), params)
}

func (s *userLoginLogService) GetUserLoginLogList(params *params.QueryParams, nickname string) (list []models.UserLoginLogResponse, paging *sqls.Paging, err error) {
	return repositories.UserLoginLogRepository.GetUserLoginLogList(sqls.DB(), &params.Cnd, nickname)
}

func (s *userLoginLogService) FindPageByCnd(cnd *sqls.Cnd) (list []models.UserLoginLog, paging *sqls.Paging) {
	return repositories.UserLoginLogRepository.FindPageByCnd(sqls.DB(), cnd)
}

func (s *userLoginLogService) Count(cnd *sqls.Cnd) int64 {
	return repositories.UserLoginLogRepository.Count(sqls.DB(), cnd)
}

func (s *userLoginLogService) Delete(id int64) {
	repositories.UserLoginLogRepository.Delete(sqls.DB(), id)
}

func (s *userLoginLogService) Create(t *models.Resources) error {
	return repositories.ResourcesRepository.Create(sqls.DB(), t)
}
